package aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.lang.Nullable;

import java.lang.reflect.Method;
import java.util.Objects;

/**
 * AfterReturningAdvice表示方法在正常返回后发出的通知（除非方法抛出异常），方法的返回值不可更改
 */
public class CustomAfterReturningAdvice implements AfterReturningAdvice {
    private Log log = LogFactory.getLog(this.getClass());

    @Override
    public void afterReturning(@Nullable Object o, Method method, Object[] objects, @Nullable Object o1) {
        log.info("在对象" + Objects.requireNonNull(o1).getClass().getName() + "调用方法" + method.getName() + "之后记录日志");
    }
}
